package com.cysd.ewmksbs.ui.activity

import android.content.Context
import android.content.Intent
import android.os.Bundle

import com.cszy.ewmxns.base.BaseVMActivity
import com.cysd.ewmksbs.ksb_adapter.DetailsAdapter

import com.cysd.ewmksbs.viewmodel.MainViewModel
import com.csylhl.ewmksb.databinding.ActivityDetail1Binding


class Ksb_DetailActivity1 : BaseVMActivity<MainViewModel, ActivityDetail1Binding>() {
    //传一个type过来通过instance
    private val type by lazy {
        intent.getStringExtra("type")
    }
    //adapter
    private var adapter: DetailsAdapter? = null

    //launch

    companion object{
        fun launch(context: Context,type: String){
            context.startActivity(
                Intent(context, Ksb_DetailActivity1::class.java).apply {
                    putExtra("type", type) // 传递type参数
                }
            )
        }
    }


    override fun initView(savedInstanceState: Bundle?) {


        setTitleWhiteStatusBar()

        mBinding.rvDetails.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this)
        adapter = DetailsAdapter()
        mBinding.rvDetails.adapter = adapter

        when (type) {
            "1" -> {
                mBinding.headTitle.headCenterTitle.text = "文字提取"
                adapter?.submitList(mViewModel.getDetailsList1())
            }
            "0" -> {
                mBinding.headTitle.headCenterTitle.text = "扫码查价"
                adapter?.submitList(mViewModel.getDetailsList())
            }
        }
    }



    override fun initListener() {
       mBinding.headTitle.headBack.setOnClickListener {
           finish()
       }
    }
}